package practice;

public class Account {
    private static final int START = 1000000;
    private int cid;
    private double balance;
    private Customer customer;

    public Account(int cid, double balance, Customer customer) {
        this.cid = cid + START;
        this.balance = balance;
        this.customer = customer;
    }

    public String getInfo() {
        return "卡号：" + cid + "\n余额：" + balance + "\n所属用户：" + customer.getName();
    }

    public boolean withdraw(double amount) {
        if (amount > 0 && amount <= balance) {
            balance -= amount;
            return true;
        }
        return false;
    }

    public boolean save(double amount) {
        if (amount > 0) {
            balance += amount;
            return true;
        }
        return false;
    }
}
